﻿using System;
using System.Collections.Generic;
using System.Web.UI;
using viBlog.Classes;
using viBlog.Controllers;
using visinia.SmartEngine;
using visinia.SmartEngine.Modules;

public partial class Modules_viBlog_Archives_Archives : WebModule
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected override void WebModuleRender(HtmlTextWriter output)
    {
        /*****************************************************************************************/
        // Archive URL = BlogArchive/Year/Month.aspx
        /*****************************************************************************************/
        List<ArchiveData> list = PostController.GetArchives();
        if (list == null)
            return;
        List<string> text = new List<string>();
        List<string> links = new List<string>();
        foreach (ArchiveData archivedata in list)
        {
            text.Add(archivedata.MonthName + "" + archivedata.Year);
            links.Add(WebRoots.GetWebRoot + BlogController.BlogUrlSeparator + "/Archive/" + archivedata.Year + "/" + archivedata.Month + ".aspx");
        }        
        string data = WebHelpers.GenerateBulletedListHyperLinks(text.ToArray(), links.ToArray());
        output.Write(data);
    }
}